package com.dura.test;

import com.dura.test.client.CacheClient;
import com.dura.test.mapper.ClientChannelMapper;
import com.dura.test.pojo.ClientChannel;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.apache.ibatis.annotations.Select;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;

import java.util.List;
import java.util.Map;

/**
 * @version 1.0
 * @Author 振鹏
 * @Date 2025/3/19 14:58
 * @注释
 */
@SpringBootTest
@RunWith(SpringRunner.class)
public class ClientChannelMapperTest {

    @Autowired
    private ClientChannelMapper mapper;

    @Autowired
    private CacheClient cacheClient;


    @Test
    public void findAll() throws JsonProcessingException {
        List<ClientChannel> list = mapper.findAll();
        for (ClientChannel clientChannel : list) {
            ObjectMapper objectMapper = new ObjectMapper();
            Map map = objectMapper.readValue(objectMapper.writeValueAsString(clientChannel), Map.class);
            cacheClient.sadd("client_channel:" + clientChannel.getClientId(),map);
        }
    }
}
